package com.ship.dispatch.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ship.common.datasource.annotation.Slave;
import com.ship.dispatch.bean.HomePage.*;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ConHomePageServerMapper extends BaseMapper<ConHomePage> {

    @Delete("DELETE FROM sp_homepage")
    void deleteAll();

    @Select("select imo from sp_homepage")
    List<String> getAllImo();

    @Slave
    List<ConHomePage> getAisStatus(@Param("imoList") List<String> imoList, @Param("tableName") String tableName);

    @Select("select * from sp_homepage")
    List<ConHomePage> getAll();

    @Select("select con_id from sp_homepage")
    List<String> getAllConId();

    List<ConHomePageAll> getByConIdList(@Param("conIdList") List<String> conIdList);

    @Select("SELECT id, imo, ship_name, expected_loading_date, expected_unloading_window, expected_unloading_window, reality_unloading_date, reality_loading_date, expected_loading_port, expected_unloading_port, reality_loading_port FROM sp_arrange_scheme_detail AS t1 WHERE imo NOT LIKE '%virtualShip%' AND expected_unloading_window IS NOT NULL AND expected_unloading_window < CURRENT_TIMESTAMP AND expected_unloading_window = ( SELECT MAX(expected_unloading_window) FROM sp_arrange_scheme_detail AS t2 WHERE t1.imo = t2.imo AND t2.expected_unloading_window IS NOT NULL AND t2.expected_unloading_window < CURRENT_TIMESTAMP )")
    List<ConHomePageArrage> getInfoByArrange();

    List<ConHomePageArrageCon> getConInfoOffHireByImo(@Param("imoList") List<String> imoList);

    List<ConHomePageArrageCon> getConInfoLeaseByImo(@Param("imoList") List<String> imoList);

    List<ConHomePageArrageCon> getConInfoLeaseByImoNow(@Param("imoList") List<String> imoList);

    @Select("SELECT DISTINCT port_name_english, port_country FROM sp_port_information")
    List<PortCountry> getPortInfo();

    List<ConHomePageArrage> getGetNowVoyageByOne(@Param("imoList") List<String> imolist);

    List<ConHomePageArrage> getGetNowVoyageByTwoNow(@Param("imoList") List<String> imolist);

    List<ConHomePageArrage> getGetNowVoyageByTwoLast(@Param("imoList") List<String> imolist);

    List<ConHomePageArrageCon> getConOffHIreNow(@Param("imoList") List<String> imolist);
}
